using System;
using System.Collections.Generic;
using System.Text;

using Nix.PBeM.Engine.DataTypes.Basic;

namespace Nix.PBeM.Engine.DataTypes.Collections
{
	/// <summary>
	/// Day intervals.
	/// </summary>
	public class DayIntervalList
	{
		List<DayInterval> intervals = new List<DayInterval>();
		
		DayInterval current = null;

		public void Start()
		{
			if (current != null)
				return;
			this.current = new DayInterval(Engine.Instance.CurrentDay);
			this.intervals.Add(this.current);
		}

		public void End()
		{
			if (current == null)
				return;
			this.current.End = Engine.Instance.CurrentDay;
		}

		/// <summary>
		/// Check if specified day is in current interval.
		/// </summary>
		/// <param name="day">The day.</param>
		/// <returns></returns>
		public bool IncludesDay ( int day )
		{
			foreach ( DayInterval intr in this.intervals )
			{
				if (intr.IncludesDay(day))
					return true;
			}
			return false;
		}
	}
}
